<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.lmpop.trade.ti_goods.Ti_goodsInfo" %>
<%@page import="com.lmpop.trade.tb_goodstock.*" %>
<%
  
  String goods_id="";  
  
  Ti_goodsInfo ti_goodsInfo = new Ti_goodsInfo();
  
  if(request.getParameter("goods_id")!=null)
	{
		 goods_id = request.getParameter("goods_id");
	}
  String goods_name = ti_goodsInfo.getGoodsNameById(goods_id);
  Tb_goodstockInfo tb_goodstockInfo = new Tb_goodstockInfo();
  Hashtable stockMap = tb_goodstockInfo.getGoodStockByGoodsId(goods_id);
  String before_num ="",now_num="";
  
  if(stockMap.get("before_num")!=null)
  {
     before_num = stockMap.get("before_num").toString(); 
  }
    
  if(stockMap.get("now_num")!=null)
  {
     now_num = stockMap.get("now_num").toString(); 
  }
  
  String cust_id="",publish_user_id="";
	if(session.getAttribute("session_cust_id")!=null){
	     cust_id  =session.getAttribute("session_cust_id").toString();
	}
  if(session.getAttribute("session_user_id")!=null){
	     publish_user_id  =session.getAttribute("session_user_id").toString();
	}
	String s_start_date="",s_end_date="";
	String iStart = "0";
	int limit = 20;
    if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	
	Hashtable paramMap = new Hashtable(); 	
	
	if(request.getParameter("s_start_date")!=null && !request.getParameter("s_start_date").equals("")){
		s_start_date = request.getParameter("s_start_date");
		paramMap.put("s_start_date",s_start_date);
	}
    if(request.getParameter("s_end_date")!=null && !request.getParameter("s_end_date").equals("")){
		s_end_date = request.getParameter("s_end_date");
		paramMap.put("s_end_date",s_end_date);
	}
	String para =	"/program/admin/stock/stockDynamic.jsp?s_end_date="+s_end_date+"&s_start_date="+s_start_date+"&goods_id="+goods_id+"&iStart="+Integer.parseInt(iStart)+"&limit="+limit;	

%> 
<html>
  <head>
    <title>tb_goodstock Manager</title>
	  <link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="js_stock.js"></script>
</head>

<body>
	<h1>更新商品库存</h1>
		
	<form action="/doTradeReg.do" method="post" name="addForm">
	
	<table width="80%" cellpadding="0" cellspacing="1" border="0" class="listtab">
		
		<tr>
			<td align="right" width="20%">
				商品:
			</td>
			<td><span style="color:#666666"><%=goods_name%></span></td>
		</tr>
      
    <tr>
			<td align="right" width="20%">
				原库存量:
			</td>
			<td><span style="color:#666666"><%=now_num%></span></td>
		</tr>
  		
		<tr>
			<td align="right" width="20%">
				 商品库存单价<font color="red">*</font>			
			</td>
			<td><input name="one_price" id="one_price" type="text" onKeyUp="if(isNaN(value))this.value=''" /></td>
		</tr>
		
		<tr>
			<td align="right" width="20%">
				 现有库存量<font color="red">*</font>			
			</td>
			<td><input name="now_num" id="now_num" type="text" onKeyUp="if(!/^[1-9][0-9]*$/.test(this.value))this.value=''" /></td>
		</tr>
		
		<tr>
			<td align="right" width="20%">
				异动原因<font color="red">*</font>			
			</td>
			<td>
				
				<textarea name="vary_reason" id="vary_reason" rows="6" cols="50" maxlength="300" onkeyup="return isMaxLen(this)" onBlur="return isMaxLen(this)"></textarea>			
			
			</td>
		</tr>
		
				
	</table>
	
	<table width="80%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td align="center">
				<input type="hidden" name="bpm_id" value="8768" />
				
				<input type="hidden" name="goods_id" value="<%=goods_id%>" />
                                                                  
       	<input type="hidden" name="cust_id" value="<%=cust_id%>" />
       	
	      <input type="hidden" name="publish_user_id" value="<%=publish_user_id%>" />
                                                                    
      	<input type="hidden" name="before_num" id="before_num" value="<%=now_num%>" />
                                                                               
        <input type="hidden" name="vary_num" id="vary_num" value="" />
      
        <input type="hidden" name="stock_num" id="stock_num" value="" />
				<input type="hidden" name="jumpurl" value="<%=para%>" />
				
				<input type="button" class="buttoncss" name="tradeSub" value="提交" onclick="updateStock();"/>&nbsp;&nbsp;
				<input type="button" class="buttoncss" name="tradeRut" value="返回" onclick="window.location.href='<%=para%>';"/>
			</td>
		</tr>
	</table>
	</form>
</body>

</html>
